<?php
@session_start();
$PurviewLevel=2;
$CheckChannelID=1;  
$PurviewLevel_Others="user_app_user";

require("../../inc/common.inc.php");
require_once("../Admin_ChkPurview.php");
$grouparr="";
$rs=$db->excu("select * from mx_app_user_group order by orderid asc,id asc");
if ($db->num_rows($rs)>0){
	while ($rsdb=$db->fetch_array($rs)){
		$grouparr[$rsdb["id"]]=$rsdb["groupname"];
	}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<TITLE>铭讯EOS网站后台管理</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<Meta name="Keywords" Content="济南网站建设 济南网站制作 山东网站建设 济南铭讯软件有限公司">
<Meta name="Description" Content="济南网站制作：铭讯软件专业服务优秀企业，致力于网站建、设网站推广、网络营销一体的全访位网络服务商">
<link rel="stylesheet" href="../images/style.css" type="text/css">
<SCRIPT LANGUAGE="JavaScript">
function ConfirmDel()
{
   if(confirm("确定要删除选中的信息吗？"))
     return true;
   else
     return false;
	 
}
function postdo(va){
	document.form2.jobs.value=va
	document.form2.submit();
}
</SCRIPT>
</head>
<body> 
<?php
if ($actions=="saveadd"){
	  $postdb=$_POST['postdb'];
	  $sex=intval($_REQUEST["sex"]);
	  $utype=intval($utype);
	  $uppassword="";
	  
	  if (trim($mobile)!=""){
		if(!eregi("^1[0-9]{10}$",$mobile))
		{
		  $fun->popmassage("手机格式不正确","","popback");
		  exit();
		}
	  }
	  $username = $mobile;
      $rs=$db->excu("SELECT * FROM mx_app_user  WHERE username='$username'");
		if($db->num_rows($rs)>0){
		  $fun->popmassage("此用户已经存在！","","popback");
		  exit();
	  }
		
		if(trim($password)==""){
		  $fun->popmassage("密码不能为空！","","popback");
		  exit();
		}
		if(trim($passwordtwo)==""){
		  $fun->popmassage("密码确认不能为空！","","popback");
		  exit();
		}
	  if ($password!="" && !empty($password) && $passwordtwo!="" && !empty($passwordtwo)){
		if ($password != $passwordtwo){
		$fun->popmassage("两次输入密码不一致，请重新输入！","","popback");
		exit();
		}
	  }
		if(trim($realname)==""){
		  $fun->popmassage("真实姓名不能为空！","","popback");
		  exit();
		}
//		if(trim($question)==""){
//		  $fun->popmassage("密码找回问题不能为空！","","popback");
//		  exit();
//		}
//		if(trim($answer)==""){
//		  $fun->popmassage("密码找回答案不能为空！","","popback");
//		  exit();
//		}
		$integral = intval($integral);
		$money = intval($money);
		$qq = intval($qq);
		$groupid=0;
		$isok=intval($isok);
		$mx_insert_fields['username'] = $username;
		$mx_insert_fields['password'] = md5($password);
		$mx_insert_fields['realname'] = $realname;
		$mx_insert_fields['sex'] = $sex;
		$mx_insert_fields['mobile'] = $mobile;
		$mx_insert_fields['mail'] = $mail;
		$mx_insert_fields['qq'] = $qq?$qq:'';
		$mx_insert_fields['integral'] = $integral;
		$mx_insert_fields['money'] = $money;
		$mx_insert_fields['regdate'] = date('Y-m-d H:i:s');
		$mx_insert_fields['groupid'] = $groupid;
		$mx_insert_fields['isok'] = $isok;
		$mx_insert_fields['address'] = $address;
		$db->exe_insert('mx_app_user', $mx_insert_fields);
		jump2("添加成功","app_user.php",2);
		exit();
}
elseif ($actions=="savemodi"){
	$id=intval($id);
	$sex=intval($sex);
	if ($id==0){
		$fun->popmassage("请选择要修改的信息","","popback");
		exit();
	}
	$postdb=$_POST['postdb'];
	  $sex=intval($_REQUEST["sex"]);
	  $utype=intval($utype);
	  $uppassword="";
	  
	  if (trim($mobile)!=""){
		if(!eregi("^1[0-9]{10}$",$mobile))
		{
		  $fun->popmassage("手机格式不正确","","popback");
		  exit();
		}
	  }
	  $username = $mobile;
      $rs=$db->excu("SELECT * FROM mx_app_user  WHERE username='$username'");
		if($db->num_rows($rs)>0){
		  $fun->popmassage("此用户已经存在！","","popback");
		  exit();
	  }
	  
	  if ($password!="" && !empty($password)){
	  	if(trim($passwordtwo)==""){
	  		$fun->popmassage("密码确认不能为空！","","popback");
	  		exit();
	  	}
		if ($password != $passwordtwo){
			$fun->popmassage("两次输入密码不一致，请重新输入！","","popback");
			exit();
		}
	  }
		if(trim($realname)==""){
		  $fun->popmassage("真实姓名不能为空！","","popback");
		  exit();
		}
//		if(trim($question)==""){
//		  $fun->popmassage("密码找回问题不能为空！","","popback");
//		  exit();
//		}
//		if(trim($answer)==""){
//		  $fun->popmassage("密码找回答案不能为空！","","popback");
//		  exit();
//		}
		$integral = intval($integral);
		$money = intval($money);
		$isok=intval($isok);
		$qq = intval($qq);
		if($password){
			$mx_update_fields['password'] = md5($password);
		}
		$mx_update_fields['realname'] = $realname;
		$mx_update_fields['sex'] = $sex;
		$mx_update_fields['mail'] = $mail;
		$mx_update_fields['qq'] = $qq?$qq:'';
		$mx_update_fields['integral'] = $integral;
		$mx_update_fields['money'] = $money;
		$mx_update_fields['modidate'] = date('Y-m-d H:i:s');
		$mx_update_fields['modiid'] = $_SESSION['mxadmin']['userid'];
		$mx_update_fields['groupid'] = $groupid;
		$mx_update_fields['isok'] = $isok;
		$mx_update_fields['address'] = $address;
		$db->exe_update('mx_app_user', $mx_update_fields,"id=$id");
    	$url=url_code($url);
		jump2("操作成功","$url",2);
    	exit();
}
elseif ($actions=="delete"){
	  global $db,$fun;
	  $id=intval($id);
	  if ($id==0){
		$fun->popmassage("请选择要删除的信息","","popback");
		exit();
	  }
	  $db->excu("delete from mx_app_user where id='$id' ");
	  $url=$fromurl?$fromurl:$FROMURL;
	  jump2("操作成功",$url,1);
	  exit();
}
elseif ($actions=="delall"){
	if ($id=="" || empty($id)){
		$fun->popmassage("请选择要删除的信息","","popback");
		exit();
	}
	if(!is_array($id)){
		$fun->popmassage("请选择要更改的信息","","popback");
		exit();
	}
	foreach( $id as $key=>$value){
		$db->excu("delete from mx_app_user where id='$key' ");
	}
	$url=$fromurl?$fromurl:$FROMURL;
	jump2("操作成功",$url,1);
	exit();
  }
elseif ($actions=="isok"){
	$id=intval($id);
	if ($id==0){
		$fun->popmassage("请选择要操作的信息","","popback");
		exit();
	}
	if ($T=="isok"){
		$upsql="update mx_app_user set isok='1',modidate='".date("Y-m-d H:i:s")."',modiid='".$_SESSION['mxadmin']['userid']."' where id='$id'";
	}
	else{
		$upsql="update mx_app_user set isok='0',modidate='".date("Y-m-d H:i:s")."',modiid='".$_SESSION['mxadmin']['userid']."' where id='$id'";
	}
	
	$db->excu($upsql);
	$url=$fromurl?$fromurl:$FROMURL;
	jump2("操作成功",$url,1);
	exit();
}
elseif ($actions=="pisok"){
	if ($id=="" || empty($id)){
		$fun->popmassage("请选择要更改的信息","","popback");
		exit();
	}
	if(!is_array($id)){
		$fun->popmassage("请选择要更改的信息","","popback");
		exit();
	}
	foreach( $id as $key=>$value){
		$db->excu("update mx_app_user set isok='1',modidate='".date("Y-m-d H:i:s")."',modiid='".$_SESSION['mxadmin']['userid']."' where id='$key' ");
	}
	$url=$fromurl?$fromurl:$FROMURL;
	jump2("操作成功",$url,1);
	exit();
}
elseif ($actions=="pnoisok"){
	if ($id=="" || empty($id)){
		$fun->popmassage("请选择要更改的信息","","popback");
		exit();
	}
	if(!is_array($id)){
		$fun->popmassage("请选择要更改的信息","","popback");
		exit();
	}
	foreach( $id as $key=>$value){
		$db->excu("update mx_app_user set isok='0',modidate='".date("Y-m-d H:i:s")."',modiid='".$_SESSION['mxadmin']['userid']."' where id='$key' ");
	}
	$url=$fromurl?$fromurl:$FROMURL;
	jump2("操作成功",$url,1);
	exit();
}

require("../mx_head.php");?>
<div class="right">
<?php  
  if ($actions=="add"){
?>
<script language="javascript">
 function CheckAdd(){
	if(document.form1.username.value==""){
	   alert("请输入用户名！");
	   document.form1.username.focus();
	   return false;
	}
 
	if(document.form1.password.value==""){
	  alert("请输入密码！");
	  document.form1.password.focus();
	  return false;
	}else{
	 if(document.form1.password.value.length<6){
	    alert("密码不能少于6个字符!"); 
	    document.form1.password.focus();
		return false;
	 }
	}
	if(document.form1.affirmpw.value==""){
	  alert("请输入确认密码！");
	  document.form1.affirmpw.focus();
	  return false;
	}else{
	  if(document.form1.affirmpw.value==document.form1.password.value){
	   
	  }else{
	     alert("两次输入的密码不同！");
	     document.form1.affirmpw.focus();
		 return false;
	  }
	}
//	if(document.form1.realname.value==""){
//	   alert("请输入真实姓名！");
//	   document.form1.realname.focus();
//	   return false;
//	}
	
	if(document.form1.mail.value==""){
	}else{
	  var str = document.form1.mail.value;
	  var reg = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
	  var flag = reg.test(str);
	  if(!flag){
		 alert("正确填写您的E_mail地址");
		 return false;
			document.form1.mail.focus();
	  }
	}
		
}
</script>
<div class="xm2">
<h1 class="fl">添加APP用户</h1>
</div>
<div class="xm2_b">
<div class="height15"></div>
<table width="100%" border="0" cellspacing="1" cellpadding="5" class="table_southidc">
  <form name="form1" method="post" action="app_user.php" onSubmit="return CheckAdd();">
	<TR class="list1">
	  <TD width="24%">手机号码：<font style="float:right;"color="red">*</font></TD>
	  <TD width="76%"><input type="text" name="mobile" id="mobile" size="30" value="<?php echo $rsdb[mobile]?>"></TD>
	</TR>
    <tr class="list1"> 
      <td width="24%">密码:<font style="float:right;"color="red">*</font></td>
      <td width="76%"> 
        <input type="password" name="password" id="password" size="30"></td>
    </tr>
    <tr class="list1"> 
      <td width="24%">密码确认:<font style="float:right;"color="red">*</font></td>
      <td width="76%"> 
        <input type="password" name="passwordtwo" id="affirmpw" size="30"></td>
    </tr>
<!-- 	<TR class="list1"> -->
<!-- 	  <TD>密码问题：</TD> -->
<!-- 	  <TD><input type="text" name="question" id="question" size="38" value=""></TD> -->
<!-- 	</TR> -->
<!--     <tr class="list1">  -->
<!--       <td width="24%">问题回答:</td> -->
<!--       <td width="76%">  -->
<!--         <input type="password" name="answer" id="answer" size="30">        (如果不更换,请留空) </td> -->
<!--     </tr> -->
<TR class="list1">
  <TD>真实姓名：<font style="float:right;"color="red">*</font></TD>
  <TD><input type="text" name="realname" id="realname" size="38" value=""></TD>
</TR>
<TR class="list1">
  <TD>性别：<font style="float:right;"color="red">*</font></TD>
  <TD><input type="radio" name="sex" value="1" class="input_check" checked="checked" />&nbsp;男&nbsp;<input type="radio" name="sex" value="2" class="input_check"/>&nbsp;女</TD>
</TR>
<TR class="list1">
  <TD>QQ号码：</TD>
  <TD><input type="text" name="qq" id="qq" size="38" value="<?php echo $rsdb[qq]?>"></TD>
</TR>
<TR class="list1">
  <TD>E_mail：</TD>
  <TD><input type="text" name="mail" id="mail" size="38" value=""></TD>
</TR>
<TR class="list1">
  <TD>积分：</TD>
  <TD><input type="text" name="integral" id="integral" value="<?php echo $rsdb[integral]?$rsdb[integral]:0;?>"></TD>
</TR>
<TR class="list1">
  <TD>现金：</TD>
  <TD><input type="text" name="money" id="money" value="<?php echo $rsdb[money]?$rsdb[money]:0;?>"></TD>
</TR>
<TR class="list1">
  <TD>地址：</TD>
  <TD><input type="text" name="address" id="address" size="38" value="<?php echo $rsdb[address];?>"></TD>
</TR>
    <tr class="list1"> 
      <td width="24%">验证与否:<font style="float:right;"color="red">*</font></td>
      <td width="76%"> 
        <input type="radio" name="isok" value="1" checked="checked" class="input_check">
        已验证 
        <input type="radio" name="isok" value="0" class="input_check">
        未验证 </td>
    </tr>
    <tr class="list1"> 
      <td width="24%">&nbsp;</td>
      <td width="76%"> 
        <input type="submit" name="Submit" value="添 加" class="button">
		<input type="hidden" name="actions" value="saveadd">
      </td>
    </tr>
  </form>
</table>
<div class="clear"></div>
<div class="height15"></div>
</div>
<?php
  }
  elseif ($actions=="modipurview"){
//修改管理员
  global $db,$fun;
  $id=trim($_REQUEST['id']);
  if ($id=="" || empty($id)){
  	$fun->popmassage("此信息不存在！","","popback");
	exit();
  }
  $rsdb=$db->excu("select * from mx_app_user where id='$id' limit 1");
  $rsnum=$db->num_rows($rsdb);
  if ($rsnum!=1){
    $fun->popmassage("此信息不存在！","","popback");
    exit();
  }
  $rsdb=$db->fetch_array($rsdb);
  //获得阅读权限
  $userfid=explode(",",$rsdb[grouppurview]);
  $userfidstr="|||";
  foreach ($userfid as $key =>$value){
    $userfidstr.=$value."|||";
  }
  
  $isokdb[intval($rsdb[isok])]=' checked ';
  $sex[intval($rsdb[sex])]=' checked ';
  $isqq[intval($rsdb[isqq])]=' checked ';
  if ($gotourl==""){$gotourl=url_encode($_SERVER['HTTP_REFERER']);}
?>
<script language="javascript">
 function CheckAdd(){
if(document.form1.password.value!="" || document.form1.affirmpw.value!=""){  
	if(document.form1.password.value==""){
	  alert("请输入密码！");
	  document.form1.password.focus();
	  return false;
	}else{
	 if(document.form1.password.value.length<6){
	    alert("密码不能少于6个字符!"); 
	    document.form1.password.focus();
		return false;
	 }
	}
	if(document.form1.affirmpw.value==""){
	  alert("请输入确认密码！");
	  document.form1.affirmpw.focus();
	  return false;
	}else{
	  if(document.form1.affirmpw.value==document.form1.password.value){
	   
	  }else{
	     alert("两次输入的密码不同！");
	     document.form1.affirmpw.focus();
		 return false;
	  }
	}
}  
//	if(document.form1.realname.value==""){
//	   alert("请输入真实姓名！");
//	   document.form1.realname.focus();
//	   return false;
//	}
		
	if(document.form1.mail.value==""){
	}else{
	  var str = document.form1.mail.value;
	  var reg = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
	  var flag = reg.test(str);
	  if(!flag){
		 alert("正确填写您的E_mail地址");
		 return false;
			document.form1.mail.focus();
	  }
	}
}
function modifPwd(that){
	var already = $(that).hasClass('already');
	if(already){
		$(that).removeClass('already').html('修改密码');
		$(".modifpwd").find("#password").val('');
		$(".modifpwd").find("#passwordtwo").val('');
		$(".modifpwd").hide();
	}else{
		$(that).addClass('already').html('取消修改');
		$(".modifpwd").show();
	}
}
</script>
<div class="xm2">
<h1 class="fl">修改APP用户信息</h1>
</div>
<div class="xm2_b">
<div class="height15"></div>
<table width="100%" border="0" cellspacing="1" cellpadding="8" class="table_southidc">
  <form name="form1" method="post" action="app_user.php" onSubmit="return CheckAdd();">
    <tr class="list1"> 
      <td width="24%">用户名:</td>
      <td width="76%"> 
        <?php echo $rsdb[username]?>&nbsp;&nbsp;<a href="javascript:void(0);" onclick="modifPwd(this)">修改密码</a></td>
    </tr>
     <tr class="list1 modifpwd" style="display: none;"> 
      <td width="24%">密码:</td>
      <td width="76%"> 
        <input type="password" name="password" id="password" size="30"></td>
    </tr>
    <tr class="list1 modifpwd" style="display: none;"> 
      <td width="24%">密码确认:</td>
      <td width="76%"> 
        <input type="password" name="passwordtwo" id="passwordtwo" size="30"></td>
    </tr>
    <tr class="list1"> 
      <td width="24%">用户ID:</td>
      <td width="76%"> 
        <?php echo $rsdb[id]?></td>
    </tr>
	<?php 
	if (trim($rsdb["faceurl"])!=""){
	$faceurl=get_face($rsdb);
	?>
    <tr class="list1"> 
      <td width="24%">用户头像:</td>
      <td width="76%"><img src="<?php echo $faceurl;?>" width="80" height="80" /></td>
    </tr>
	<?php }?>
    <!--<tr class="list1" style="display:none"> 
      <td width="24%">密码:</td>
      <td width="76%"> 
        <input type="password" name="password" id="password" size="30">(如果不更换密码,请留空) </td>
    </tr>
    <tr class="list1" style="display:none;"> 
      <td width="24%">密码确认:</td>
      <td width="76%"> 
        <input type="password" name="passwordtwo" id="affirmpw" size="30">(如果不更换密码,请留空) </td>
    </tr>
	<TR class="list1" style="display:none;">
	  <TD>密码问题：</TD>
	  <TD><input type="text" name="question" id="question" size="38" value="<?php echo trim($rsdb[question])?>"></TD>
	</TR>
    <tr class="list1" style="display:none;"> 
      <td width="24%">问题回答:</td>
      <td width="76%"> 
        <input type="password" name="answer" id="answer" size="30">        (如果不更换,请留空) </td>
    </tr>-->
<TR class="list1">
  <TD>所属分组：</TD>
  <TD><select name="groupid"><option value="">不限</option><?php echo show_select($grouparr,$rsdb["groupid"]);?></select></TD>
</TR>
<TR class="list1">
  <TD>真实姓名：</TD>
  <TD><input type="text" name="realname" id="realname" size="38" value="<?php echo trim($rsdb[realname])?>"></TD>
</TR>
<TR class="list1">
  <TD>性别：</TD>
  <TD><input type="radio" name="sex" value="1" class="input_check" <?php echo $sex[1]?> />&nbsp;男&nbsp;<input type="radio" name="sex" value="2" class="input_check" <?php echo $sex[2]?>/>&nbsp;女</TD>
</TR>
<TR class="list1">
  <TD>手机号码：</TD>
  <TD><?php echo trim($rsdb[mobile])?></TD>
</TR>
<TR class="list1">
  <TD>QQ号码：</TD>
  <TD><input type="text" name="qq" id="qq" size="38" value="<?php echo trim($rsdb[qq])?>"></TD>
</TR>
<TR class="list1">
  <TD>E_mail：</TD>
  <TD><input type="text" name="mail" id="mail" size="38" value="<?php echo trim($rsdb["mail"])?>"></TD>
</TR>
<TR class="list1">
  <TD>积分：</TD>
  <TD><input type="text" name="integral" id="integral" value="<?php echo $rsdb[integral]?$rsdb[integral]:0;?>"></TD>
</TR>
<TR class="list1">
  <TD>现金：</TD>
  <TD><input type="text" name="money" id="money" value="<?php echo $rsdb[money]?$rsdb[money]:0;?>"></TD>
</TR>
<TR class="list1">
  <TD>地址：</TD>
  <TD><input type="text" name="address" id="address" size="38" value="<?php echo $rsdb[address];?>"></TD>
</TR>
    <tr class="list1"> 
      <td width="24%">验证与否:</td>
      <td width="76%"> 
      <input type="radio" name="isok" value="1" <?php echo $isokdb[1]?> class="input_check">
      正常
      <input type="radio" name="isok" value="0" <?php echo $isokdb[0]?> class="input_check">
      锁定
	  </td>
    </tr>
    <tr class="list1"> 
      <td width="24%">&nbsp;</td>
      <td width="76%"> 
        <input type="submit" name="Submit" value="修 改" class="button">
		<input type="hidden" name="url" value="<?php echo $gotourl?>">
        <input type="hidden" name="id" value="<?php echo $rsdb[id]?>">
		<input type="hidden" name="actions" value="savemodi">
      </td>
    </tr>
  </form>
</table>
<div class="clear"></div>
<div class="height15"></div>
</div>
<?php
  }
  elseif ($actions=="view"){
//修改管理员
  global $db,$fun;
  $id=trim($_REQUEST['id']);
  if ($id=="" || empty($id)){
  	$fun->popmassage("此信息不存在！","","popback");
	exit();
  }
  $rsdb=$db->excu("select * from mx_app_user where id='$id' limit 1");
  $rsnum=$db->num_rows($rsdb);
  if ($rsnum!=1){
    $fun->popmassage("此信息不存在！","","popback");
    exit();
  }
  $rsdb=$db->fetch_array($rsdb);
?>
<div class="xm2">
<h1 class="fl">APP用户详细信息</h1>
</div>
<div class="xm2_b">
<div class="height15"></div>
<table width="100%" border="0" cellspacing="1" cellpadding="8" class="table_southidc">
  <form name="form1" method="post" action="app_user.php" onSubmit="return CheckAdd();">
    <tr class="list1" style="display:none;"> 
      <td width="15%">用户名:</td>
      <td width="85%"> 
        <?php echo $rsdb[username]?></td>
    </tr>
    <tr class="list1"> 
      <td width="15%">用户ID:</td>
      <td width="85%"> 
        <?php echo $rsdb[id]?></td>
    </tr>
	<?php 
	if (trim($rsdb["faceurl"])!=""){
	$faceurl=get_face($rsdb);
	?>
    <tr class="list1"> 
      <td>用户头像:</td>
      <td><img src="<?php echo $faceurl;?>" width="80" height="80" /></td>
    </tr>
	<?php }?>
    <!--<tr class="list1" style="display:none"> 
      <td>密码:</td>
      <td> 
        <input type="password" name="password" id="password" size="30">(如果不更换密码,请留空) </td>
    </tr>
    <tr class="list1" style="display:none;"> 
      <td>密码确认:</td>
      <td> 
        <input type="password" name="passwordtwo" id="affirmpw" size="30">(如果不更换密码,请留空) </td>
    </tr>
	<TR class="list1" style="display:none;">
	  <TD>密码问题：</TD>
	  <TD><input type="text" name="question" id="question" size="38" value="<?php echo trim($rsdb[question])?>"></TD>
	</TR>
    <tr class="list1" style="display:none;"> 
      <td>问题回答:</td>
      <td> 
        <input type="password" name="answer" id="answer" size="30">        (如果不更换,请留空) </td>
    </tr>-->
<TR class="list1">
  <TD>所属分组：</TD>
  <TD><?php echo $rsdb["groupid"]==0?"未分组":$grouparr[$rsdb["groupid"]];?></TD>
</TR>
<TR class="list1">
  <TD>真实姓名：</TD>
  <TD><?php echo trim($rsdb[realname])==""?"未知":trim($rsdb[realname])?></TD>
</TR>
<TR class="list1">
  <TD>性别：</TD>
  <TD><?php if ($rsdb["sex"]==1){echo "男";}else{echo "女";}?></TD>
</TR>
<TR class="list1">
  <TD>手机号码：</TD>
  <TD><?php echo trim($rsdb[mobile])==""?"未知":trim($rsdb[mobile])?></TD>
</TR>
<TR class="list1">
  <TD>QQ号码：</TD>
  <TD><?php echo trim($rsdb[qq])==""?"未知":trim($rsdb[qq])?></TD>
</TR>
<TR class="list1">
  <TD>E_mail：</TD>
  <TD><?php echo trim($rsdb["mail"])==""?"未知":trim($rsdb["mail"])?></TD>
</TR>
<TR class="list1">
  <TD>最后位置：</TD>
  <TD><?php echo ($rsdb["province"]==""&&$rsdb["city"]==""&&$rsdb["district"]==""&&$rsdb["address"]=="")?"未知":$rsdb["province"]."&nbsp;".$rsdb["city"]."&nbsp;".$rsdb["district"]."&nbsp;".$rsdb["address"]?></TD>
</TR>
<TR class="list1">
  <TD>关注时间：</TD>
  <TD><?php echo $rsdb["regdate"]?></TD>
</TR>
<TR class="list1">
  <TD>登陆次数：</TD>
  <TD><?php echo $rsdb["logintimes"]?></TD>
</TR>
<TR class="list1">
  <TD>最后登陆时间：</TD>
  <TD><?php echo $rsdb["lastlogintime"]==""?"未知":$rsdb["lastlogintime"]?></TD>
</TR>
    <tr class="list1"> 
      <td>验证与否:</td>
      <td><?php if ($rsdb["isok"]==1){echo "正常";}else{echo "锁定";}?>
	  </td>
    </tr>
    <tr class="list1"> 
      <td>&nbsp;</td>
      <td> 
        <input type="button" name="back" value="返 回" class="button" onclick="history.back();">
      </td>
    </tr>
  </form>
</table>
<div class="clear"></div>
<div class="height15"></div>
</div>
<?php
  }
  else{
  $s="T=$T&";
  $str="";

  if ($username!=""){
    $str.=" and username like '%$username%' ";
	$s.="username=$username&";
  }
  if ($groupid!=""){
  	$groupid=intval($groupid);
    $str.=" and groupid='$groupid' ";
	$s.="groupid=$groupid&";
  }
  if ($mobile!=""){
    $str.=" and mobile like '%$mobile%' ";
	$s.="mobile=$mobile&";
  }
  if ($isok!=""){
  	$isok=intval($isok);
    $str.=" and isok='$isok' ";
	$s.="isok=$isok&";
  }
  if ($sex!=""){
  	$sex=intval($sex);
    $str.=" and sex='$sex' ";
	$s.="sex=$sex&";
  }

  
  if ($T=="isok"){
    $str.=" and isok='1' ";
  }
  elseif ($T=="noisok"){
    $str.=" and isok='0' ";
  }

  if(empty($pageindex)){
      $pageindex=1;
  }
  $pagesize=intval($pagesize);
  if ($pagesize==0){
  	$pagesize=20;
  }

  $table=" mx_app_user ";
  $order=" order by id desc";
  $column=" * ";
  $biaoid="id";
  $c=$db->listcount($table,$str);
  $list=$db->list1($pageindex,$pagesize,$table,$column,$str,$order,$biaoid);
 ?>
<div class="gk">
			<div class="ti2 fl">APP用户管理</div>
			<ul class="fr">
				<li><span class="c1"><?php $znum=$db->listcount("mx_app_user","");echo $znum;?></span><span>总条数</span></li>
				<li class="line"></li>
				<li><span class="c2"><?php $znum=$db->listcount("mx_app_user"," and isok='1'");echo $znum;?></span><span>正常</span></li>
				<li class="line"></li>
				<li><span class="c3"><?php $znum=$db->listcount("mx_app_user"," and isok='0'");echo $znum;?></span><span>禁用</span></li>
			</ul>
			<div class="clear"></div>
</div>
<div class="height15"></div>

<div class="xm2">
<h1 class="fl">用户管理</h1>
</div>
<div class="xm2_b" style="border-bottom:0px;">
<div class="t">
	<table width="100%" border="0" cellpadding="0" cellspacing="0">
	<tr>
	<td>
	<div class="an1"><a href="app_user.php">APP用户管理</a></div>
	<div class="an2"><a href="app_user.php?actions=add">添加用户</a></div>
	<div class="an2"><a href="app_user.php?isok=1">正常</a></div>
	<div class="an2"><a href="app_user.php?isok=0">禁用</a></div>
	</td>
	</tr>
	</table>
</div>
<div class="t">
<table border="0" cellpadding="0" cellspacing="1" class="search_from">
<form name="searchform1" id="searchform1" action="app_user.php" method="post">
 <tr>
   <td>&nbsp;手机：</td><td><input name="mobile" type="text" id="mobile" value="" size="10" class="search_input"/></td>
   <td>&nbsp;分组：</td><td>
   <select name="groupid"><option value="">不限</option><?php echo show_select($grouparr,"");?></select>
   </td>
   <td><select name="sex"><option value="">不限</option><option value="1">男</option><option value="0">女</option></select></td>
  <td><select name="isok"><option value="">不限</option><option value="1">正常</option><option value="0">锁定</option></select></td>
  <td><select name="pagesize"><option value="20">20条/页</option><option value="30" <?php if ($pagesize==30){echo "selected";}?>>30条/页</option><option value="50" <?php if ($pagesize==50){echo "selected";}?>>50条/页</option></select></td>
  <td><input type="submit" name="Submit3" value="搜索" class="button2" /></td>
  </tr>
</form>
</table>
</div>
<div class="height10"></div>
</div>

<div class="xm2_b">
<table width="100%" border="0"  cellspacing="1" cellpadding="8" class="table_southidc">
  <tr align="center"> 
    <th width="5%">选择</th>
    <th width="12%">用户ID</th>
    <th width="12%">加入时间</th>
    <th width="15%">手机号</th>
    <th width="12%">所属分组</th>
    <th width="10%">活跃度(%)</th>
    <th width="12%">最后登陆</th>
    <th width="7%">状态</th>
    <th width="22%">操作</th>
  </tr>
  <form name="form1" id="form1" method="post" action="app_user.php">
  <?PHp
		if (!is_array($list) or $c==0){
			echo "<tr class=\"list1\"><td colspan=9><center>暂无信息</center></td></tr>";
		}else{
			for($i=0;$i<count($list);$i++){
  ?>
  <tr class="list" align="center"> 
    <td width="5%"><input type="checkbox" name="id[<?php echo $list[$i]["id"] ?>]" value="<?php echo $list[$i]["id"] ?>" class="input_check"></td>
    <td><a href="app_user.php?actions=view&id=<?php echo $list[$i]["id"] ?>"><?php echo $list[$i]["id"] ?></a></td>
	<td><a href="app_user.php?actions=view&id=<?php echo $list[$i]["id"] ?>"><?php echo formatdate($list[$i]["regdate"]);?></a></td>
    <td><a href="app_user.php?actions=view&id=<?php echo $list[$i]["id"] ?>"><?php echo $list[$i]["mobile"]==""?"未知":$list[$i]["mobile"] ?></a></td>
    <td><?php echo $list[$i]["groupid"]==0?"未分组":$grouparr[$list[$i]["groupid"]]?></td>
    <td><?php echo (float)$list[$i]["huoyue"] ?></td>
	<td><?php echo $list[$i]["lastlogintime"]==""?"未知":formatdate($list[$i]["lastlogintime"]);?></td>
    <td>
	<?php 
	if($list[$i][isok]==1){
			echo "<A HREF='app_user.php?actions=isok&id=".$list[$i][id]."&T=noisok' style='color:red;'>正常</A>";
	}
	else{
			echo "<A HREF='app_user.php?actions=isok&id=".$list[$i][id]."&T=isok' style='color:blue;'>锁定</A>";
	}
	?>
	</td>
    <td>
	  <a href="/mxsoft/tuisong/app_post.php?id=<?php echo $list[$i]["id"] ?>">推送信息</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="app_user.php?actions=modipurview&id=<?php echo $list[$i]["id"] ?>">修改</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="app_user.php?actions=delete&id=<?php echo $list[$i]["id"] ?>" onClick="return confirm('你确实要删除此会员吗?不可恢复,你考虑清楚')">删除</a></td>
  </tr>
  <?PHP
			}
  ?>
  <?php }?>
  <input type="hidden" name="actions" id="actions" value="delall">
  </form>
</table>
<?php if ($c>0){?>
	<div class="height15"></div>
	<div class="do_div">
	<div class="l"><a href="javascript:CheckAll(document.form1,'all')">全选</a>&nbsp;<a href="javascript:CheckAll(document.form1,'')">反选</a><input type="hidden" name="jobs" value="0"></div>
	<div class="l2">
	选择操作：
	<a href="javascript:postdo('pisok');"/>正常</a>
	<a href="javascript:postdo('pnoisok');"/>锁定</a>
	<a href="javascript:if (confirm('确定要删除选中的信息吗？')){postdo('delall');}"/>删除</a>
	</div>
	</div>
	<div class="clear"></div>
<?php }
if ($c>$pagesize){
?>
	<div class="pagination">
	<?PHP
	echo $db->ThePage_mxsoft($s,$pageindex,$c,$pagesize)
	?>
	</div>
<?php }?>

<div class="clear"></div>
<div class="height10"></div>
<div class="clear"></div>
<script type="text/javascript" src="/mxsoft/js/jquerys-1.5.1.js"></script>
<script language="javascript">
$(document).ready(function(){  
	$(".table_southidc tr").mouseover(function(){   
	$(this).addClass("list2");}).mouseout(function(){   
	$(this).removeClass("list2");}) //移除该行的class   
	$(".table_southidc tr:even").addClass("list1");   
});   
</script> 

<script language="javascript">
function postdo(va){
	document.form1.actions.value=va;
	document.form1.submit();
}
</script>
</div>
<?php 
  }

?>
</div>
<?php require("../mx_foot.php");?>
<div class="clear"></div>
<div class="height10"></div>
</body>
</html>
